﻿@using Projectmanagement.Entity
@using ProjectManagement.Models 
@{
    ViewBag.Title = "ProjectType";
}

@(Html.Telerik().Grid<_ProjectType>()
    .Name("ProjectType")
    .DataKeys(keys => { keys.Add(item => item.ID); })
    .ClientEvents(events => events.OnEdit("onEdit"))
    .ToolBar(commands => commands.Insert())
    .DataBinding(dataBinding =>
    {
        dataBinding.Ajax()
            .Select("_SelectIndex", "ProjectType")
            .Insert("_InsertAjaxEditing", "ProjectType")
            .Update("_SaveAjaxEditing", "ProjectType")
            .Delete("_DeleteAjaxEditing", "ProjectType");
    })
    .Columns(columns =>
    {
        columns.Bound(item => item.Name);
        columns.Command(commands =>
        {
            commands.Edit();
            commands.Delete();
        }).Title("操作").Width(240);
    })
    .Editable(editing => editing.Mode(GridEditMode.PopUp))
    .Pageable(paging=>paging.Style(GridPagerStyles.Status).PageOnScroll(true))
    .Scrollable(c => c.Height("570px"))
    .Resizable(resizing => resizing.Columns(true))
    .Sortable()
)

<script type="text/javascript">
    function onEdit(e) {
        var taskId = e.dataItem["ID"];
        if (taskId == 0) {
        } else {
            $("#legendTitle").html("编辑项目类型");
        }
    }
</script>